import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state:{
		hasLogin:uni.getStorageSync('hasLogin') || false,
		userInfo:uni.getStorageSync('userinfo') || {}
	},
	mutations:{
		login(state,userinfo){
			state.hasLogin=true;
			state.userInfo=userinfo;
			uni.setStorageSync("hasLogin",state.hasLogin)
			uni.setStorageSync("userinfo",userinfo)
		},
		logout(state){
			state.hasLogin=false;
			state.userInfo={};
			uni.removeStorageSync("userinfo")
			uni.removeStorageSync("token");
		}
	}
})
export default store